# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

pkgname=tamarin-prover
pkgver=1.8.0
pkgrel=36
pkgdesc="The Tamarin prover for security protocol analysis"
url="https://tamarin-prover.github.io"
license=("GPL")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'graphviz' 'maude' 'haskell-hunit' 'haskell-binary-orphans'
         'haskell-binary-instances' 'haskell-blaze-builder' 'haskell-blaze-html' 'haskell-cmdargs'
         'haskell-conduit' 'haskell-fclabels' 'haskell-file-embed' 'haskell-gitrev'
         'haskell-http-types' 'haskell-lifted-base' 'haskell-resourcet' 'haskell-safe'
         'haskell-shakespeare' 'haskell-threads' 'haskell-wai' 'haskell-warp' 'haskell-yesod-core'
         'haskell-yesod-static' 'haskell-tamarin-prover-utils' 'haskell-tamarin-prover-term'
         'haskell-tamarin-prover-theory' 'haskell-tamarin-prover-sapic'
         'haskell-tamarin-prover-export' 'haskell-tamarin-prover-accountability')
makedepends=('ghc')
source=("https://github.com/tamarin-prover/tamarin-prover/archive/$pkgver/tamarin-prover-$pkgver.tar.gz")
sha512sums=('62d8da7a46d521f85fa4544c676b5c7a6d0f26770eb4169fc3aef66e9b1df61753fc1e1fca9531cbe29d971807cc04f7af80c4c9f9c4bb2bae632c6e1fb32662')

build() {
    cd $pkgname-$pkgver

    runhaskell Setup configure -O --enable-executable-dynamic --prefix=/usr \
        --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
            -fthreaded -ftest-coverage -f-build-tests --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
}

check() {
    cd $pkgname-$pkgver
    LD_LIBRARY_PATH="$PWD"/dist/build dist/build/tamarin-prover/tamarin-prover test
}

package() {
    cd $pkgname-$pkgver
    runhaskell Setup copy --destdir="${pkgdir}"

    install -Dm644 etc/filetype.vim "$pkgdir"/usr/share/vim/vimfiles/ftdetect/tamarin.vim
    install -Dm644 etc/syntax/spthy.vim "$pkgdir"/usr/share/vim/vimfiles/syntax/spthy.vim
    ln -s spthy.vim "$pkgdir"/usr/share/vim/vimfiles/syntax/sapic.vim
}
